package com.bw.dg.service.impl;

import com.bw.dg.dao.*;
import com.bw.dg.pojo.Assetgl;
import com.bw.dg.pojo.Log;
import com.bw.dg.service.AssetglService;
import com.bw.dg.util.EncoderQRCode;
import com.bw.dg.util.ErWeiMaUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
import java.util.UUID;

/**
 * @ProjectName: dg
 * @Package: com.bw.dg.service.impl
 * @ClassName: AssetglServiceimpl
 * @Author: 社会佩奇
 * @Description: AssetglServiceimpl
 * @Date: 2020/4/19 16:11
 * @Version: 1.0
 */
@Service
@Transactional
public class AssetglServiceimpl implements AssetglService {

    @Autowired
    private AssetglDao assetglDao;

    @Autowired
    private PeopleDao peopleDao;

    @Autowired
    private DeptDao deptDao;

    @Autowired
    private LogDao logDao;

    @Autowired
    private UserDao userDao;

    @Override
    public List getAssetglList() {
        return assetglDao.getAssetglList();
    }

    @Override
    public Assetgl ChaAssetglByid(String id) {
        return assetglDao.ChaAssetglByid(id);
    }

    @Override
    public void tianjiaAssetgl(Assetgl assetgl) {
        assetglDao.tianjiaAssetgl(assetgl);
    }

    @Override
    public List getzhiban() {
         return peopleDao.getzhiban();
    }

    @Override
    public List getBuMen() {
        return deptDao.getBuMen();
    }

    @Override
    public void shanchuAssetglById(String aa) {
        assetglDao.shanchuAssetglById(aa);
    }

    @Override
    public List getAssetglListByID(String id) {
        return assetglDao.getAssetglListByID(id);
    }

    @Override
    public List getAssetglListByIDZC_name(String zc_name) {
        return assetglDao.getAssetglListByIDZC_name(zc_name);
    }

    @Override
    public List<Assetgl> companyList(String ids) {
        return assetglDao.companyList(ids);
    }

    @Override
    public String erweima(String id) {
        Assetgl assetgl = assetglDao.ChaAssetglByid(id);

        SimpleDateFormat sdf =   new SimpleDateFormat("yyyyMMddHHmmssSSS" );

        Date d=new Date();

        String str=sdf.format(d);

        String imgPath = ErWeiMaUtil.uploadPath()+str+".jpg";

        String content= assetgl.getZc_name();


        EncoderQRCode.encoderQRCode(content, imgPath);

        System.out.println("imgPath:"+imgPath);

        System.out.println("encoder QRcode success");
        return imgPath;
    }

    @Override
    public void xiugaibaofeiAssetglById(String aa) {
        Assetgl assetgl = assetglDao.ChaAssetglByid(aa);
        assetgl.setZc_status("报废");
        assetglDao.xiugaibaofeiAssetglById(assetgl.getZc_status(),assetgl.getId());
    }

    @Override
    public List<Assetgl> exportList2() {
        return assetglDao.getAssetglList();
    }

    @Override
    public List getUser() {
        return userDao.getUser();
    }
}
